home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.sys.amiga.programmer
- Path: news2.interlog.com!rose!awhite
- From: awhite@user.rose.com (A White)
- Subject: overloading operator()
- Sender: news@rose.com (news)
- Organization: Rose Media Incorpoarted, Ontario, Canada
- Message-ID: <DLusrq.JzL@rose.com>
- Date: Sat, 27 Jan 1996 18:59:49 GMT
-
- I've been typing in a String class example from a C++ textbook
- (Obj-Orient Pgming in C++, Barkakati) and one portion does not work.
-
- It involves overloading operator()
-
- A stripped down version follows, with constructors/destructors and
- unnecessary variables and functions removed. The error given by
- SAS/C v6.50 is shown below the offending line...
-
- Thanks in advanc...
- Allen White
-
- // STRING.HXX
- class String {
- protected:
- char *_string;
- size_t _length;
-
- public:
- // function call operator
- SubString operator()( size_t position, size_t length );
- };
-
- ====================
- SubString operator()( size_t position, size_t length );
- ^
- String.hxx Error 1200: Syntax error in member list:
- Expected member declaration; found 'operator'.
-
- class SubString: public String
- {
- public:
- // gives the String class access to SubString
- friend String;
-
- // Constructors
- SubString( const SubString& string ):
- String( string ), _original( string._original ),
- _position( string._position ) {}
- }
-
- // STRING.CXX
- #include "String.hxx"
-
- SubString String::operator()( size_t position, size_t length )
- {
- return SubString( *this, &( _string[ position ] ), position, length );
- }
- ====================
- String.cxx Error 1374: No such member
- ' SubString String::operator ()(unsigned int , unsigned int )'.
-
-